<!DOCTYPE html>
<?php
$con =@mysqli_connect("localhost","root","root","educate");
if(!$con){
    exit("<h1>数据库连接失败</h1>");
}

// print "成功连接到数据库！";
?>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>CodeBlocks 新建工程</title>
    <link rel="stylesheet" href="../../css/001.css">
</head>
<body>

<!-- <span class="title"><a href="#">修改</a></span> -->
<nav id="new">
    <?php
    mysqli_select_db($con,"resource");
    $sql = "SELECT * FROM resource";
    $result = mysqli_query($con,$sql);
    echo("<table width=‘80%' border=1 align='center' cellpadding=5 cellspacing=0>");
    echo("<tr><td>文件名</td><td>下载链接</td><td>文件格式</td></tr>");
    if(mysqli_num_rows($result)>0){


        while($rows=mysqli_fetch_assoc($result)){
        echo("<tr>");
        echo("<td>".$rows["文件名"]."</td>");
        echo("<td> <a href=".$rows["下载链接"]." title='点击下载'> 点击下载</a></td>");
        echo("<td>".$rows["文件格式"]."</td>");
        echo("</tr>");
        }
    }
    // 第五步：释放结果集
    mysqli_free_result($result);
    // 第六步：关闭连接
    mysqli_close($con);
?>

</nav>

</body>
</html>
